package main

import (
	"fmt"
	"math"
)

type Square struct {
	side float32
}

type Circle struct {
	radius float32
}

type Shaper interface {
	Area() float32
}

func main() {
	var areaInterface Shaper
	sq1 := new(Square)
	sq1.side = 5
	areaInterface = sq1
	if t, ok := areaInterface.(Square); ok {
		fmt.Printf("areaInterface 的类型是: %T\n", t)
	}

	if u, ok := areaInterface.(*Circle); ok {
		fmt.Printf("areaInterface 的类型是: %T\n", u)
	} else {
		fmt.Printf("areaInterface 不包含有 Circle类型的变量")
	}

}

func (sq Square) Area() float32 {
	return sq.side * sq.side
}

func (ci *Circle) Area() float32 {
	return ci.radius * ci.radius * math.Pi
}
